#include "dominion.h"
#include "testutils.h"
#include <stdio.h>
#include <stdlib.h>

// This unit test was added after suspicious behavior of the mine card was
// detected with random testing. All combinations of treasure cards being
// trashed and treasure cards being gained are tested.

void testMineEffect (   int args[MAX_PLAYARGS], int cardtypes[MAX_PLAYARGS],
                        carddesc_t desc, struct gameState *g,
                        expectedState_t *expected )
{
    expected->count[cardtypes[1]]--;
    expected->count[cardtypes[2]]++;
    
    bool expect_fail =  (cardtypes[1] == copper && cardtypes[2] == gold) ||
                        cardtypes[1] < copper || cardtypes[1] > gold ||
                        cardtypes[2] < copper || cardtypes[2] > gold;
    
    pass_printf (   "%s: TEST trashing %s in favor of %s using %s\n", 
                    __func__, desc[1], desc[2], desc[0] );
    
    testPlayCard (args[0], args[1], args[2], args[3], g, expected, expect_fail);
    
    testEndTurn (g, expected);
}

int main (int argc, char *argv[])
{
    parse_args (argc, argv);
    
    static playargs_t playargs =
    {
        {arg_handcard,  mine, mine},
        {arg_handcard,  0, treasure_map},
        {arg_cardtype,  0, treasure_map},
    };
    
    run_cardtest (playargs, testMineEffect);
    
    return EXIT_SUCCESS;
}
